//
//  LogoutViewController.swift
//  ElectricStationBoard
//
//  Created by Galaxy on 16/6/30.
//  Copyright © 2016年 Iris. All rights reserved.
//

import UIKit

class LogoutViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.whiteColor();
        
        //退出按钮
        let btn = UIButton(type: .System);
        btn.backgroundColor = UIColor.orangeColor();
        btn.setTitleColor(UIColor.whiteColor(), forState: .Normal);
        btn.frame = CGRectMake(100, 100, 80, 50);
        btn.setTitle("退出", forState: .Normal);
        btn.addTarget(self, action: #selector(LogoutViewController.logout), forControlEvents: .TouchUpInside);
        self.view.addSubview(btn);


    }

    func logout() ->Void {
        let userDefault = NSUserDefaults.standardUserDefaults();
        userDefault.removeObjectForKey("name");
        userDefault.removeObjectForKey("password");
        userDefault.synchronize();
        self.dismissViewControllerAnimated(true, completion: nil);
        //跳转到之前页面
        let story = UIStoryboard(name: "Main", bundle: nil);
        let vc3 = story.instantiateViewControllerWithIdentifier("me");
        self.showViewController(vc3, sender: self);
        print("注销成功");
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
